package com.anhdt.model;

import com.anhdt.dao.PostDAO;
import com.anhdt.vo.PostVO;
import com.anhdt.vo.SearchResultVO;
import java.sql.SQLException;
import java.util.List;

public class Post {

    private static Post Post;

    private Post() {
    }

    public static Post getInstance() {
        if (Post == null) {
            Post = new Post();
        }
        return Post;
    }

    private final PostDAO post = PostDAO.getInstance();

    public PostVO getPostById(int id) throws SQLException {
        return this.post.getPostDetailById(id);
    }

    public List<PostVO> getListPostForIndex() throws SQLException {
        return this.post.getListPostForIndex();
    }

    public SearchResultVO search(String key, int pageNumber) throws SQLException {
        return this.post.search(key, pageNumber);
    }
}
